<div class="uk-clearfix list-header">
  <h4 class="tm-article-subtitle uk-float-left"> 内容管理</h4>

  <div class="uk-float-right">
    <%= link_to new_backend_micopost_path, class: 'uk-button uk-button-success' do %>
      <i class="uk-icon-plus"></i> 新增
    <% end %>
  </div>
</div>
<hr>
<div class="list-search uk-form">
  <%= search_form_for @search, url: backend_micoposts_path, html: {class: 'form'} do |f| %>
    <%#= f.text_field :name_cont, placeholder: '填写姓名' %>
    <label class="uk-form-label"> 状态 </label>
    <%= f.select :status_eq, @micoposts.options_for_enum_select(:statuses, raw: true), include_blank: '全部状态' %>
    <button class="uk-button">搜索</button>
  <% end %>
</div>

<div class="uk-margin-top list-body">
  <div class="uk-overflow-container thin-scroll" style="min-height: calc(100vh - 220px);max-height:calc(100vh - 220px); ">
    <table class="uk-table uk-table-hover uk-table-striped uk-table-condensed  horizontal-scroll" border="1">
      <thead>
      <tr>
        <th>
          <%= sort_link @search, :uid do %>
            用户名
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :content do %>
            内容
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :status do %>
            审核
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :created_at do %>
            创建时间
          <% end %>
        </th>
        <th>
          <%= sort_link @search, :updated_at do %>
            修改时间
          <% end %>
        </th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      <% @micoposts.each do |micopost| %>
        <tr>
          <td><%= micopost.user.name %></td>
          <td><%= micopost.content %></td>
          <td>
            <%#=can? :show, :micopost %>
            <% if can? :switch,micopost %>
              <%= link_to switch_backend_micopost_path(micopost), method: :put, data: {confirm: "确认#{micopost.active? ? '屏蔽' : '启用'}该内容吗？"}, class: "uk-button uk-button-mini #{'uk-button-primary' if micopost.active?}" do %>
                <%= micopost.enum_name(:status) %>
              <% end %>
            <% else %>
              <%= micopost.enum_name(:status) %>
            <% end %>

          </td>
          <td><%= flatten_time micopost.created_at %></td>
          <td><%= flatten_time micopost.updated_at %></td>
          <td>
            <%= link_to edit_backend_micopost_path(micopost), class: 'uk-button uk-button-mini uk-button-primary' do %>
              <i class="uk-icon-edit"></i> 修改
            <% end %>
            <%= link_to backend_micopost_path(micopost), class: 'uk-button uk-button-mini uk-button-primary' do %>
              <i class="uk-icon-list"></i> 详情
            <% end %>
          </td>
        </tr>
      <% end %>
      </tbody>
    </table>
    <div class="paginate-info uk-clearfix uk-margin-bottom">
      <div class="uk-float-left">
        <%= paginate_info(@micoposts) %>
      </div>
      <div class="uk-float-right">
        <%= paginate @micoposts, theme: 'admin' %>
      </div>
    </div>

  </div>
</div>
